package demoMod.invincibleOne.cards.invincible;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.defect.ChannelAction;
import com.megacrit.cardcrawl.actions.defect.IncreaseMaxOrbAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.orbs.AbstractOrb;
import com.megacrit.cardcrawl.orbs.Frost;
import com.megacrit.cardcrawl.orbs.Lightning;
import demoMod.invincibleOne.InvincibleOneMod;

public class Superconductor extends AbstractInvincibleCard {
    public static final String ID = InvincibleOneMod.makeID("Superconductor");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/Superconductor.png";

    private static final CardType TYPE = CardType.POWER;
    private static final CardRarity RARITY = CardRarity.BASIC;
    private static final CardTarget TARGET = CardTarget.NONE;

    private static final int COST = 0;

    public Superconductor() {
        super(ID, NAME, InvincibleOneMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        isInnate = true;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        };
    }


    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new IncreaseMaxOrbAction(1));

        if (upgraded) {
            for (int i = 0; i <= AbstractDungeon.player.orbs.size(); i++) {
                addToBot(new ChannelAction(new Lightning()));
            }
            for (int i = 0; i <= AbstractDungeon.player.orbs.size(); i++) {
                addToBot(new ChannelAction(new Frost()));
            }
        } else {
            for (int i = 0; i <= AbstractDungeon.player.orbs.size(); i++) {
                AbstractOrb[] orbs = {new Frost(), new Lightning()};
                addToBot(new ChannelAction(orbs[AbstractDungeon.cardRandomRng.random(orbs.length - 1)]));
            }
        }
    }
}
